///
/// 刷新控件工具集
///
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_wan_android/config.dart';
import 'package:flutter_wan_android/utils/resource_mananger.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import 'activity_indicator.dart';

///
/// 二楼配置
///
class HomeSecondFloorOuter extends StatelessWidget {
  final Widget child;

  HomeSecondFloorOuter(this.child);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: HomeRefreshHeight + MediaQuery.of(context).padding.top + 20,
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(ImageHelper.wrapImageAssets('gank_io_banner.jpg')),
          fit: BoxFit.fill,
        ),
      ),
      child: Stack(
        children: <Widget>[
          Align(
            alignment: Alignment.center,
            child: Text('干货集中营',
                style: Theme.of(context).textTheme.overline.copyWith(
                      color: Colors.white,
                      fontSize: 22,
                      fontWeight: FontWeight.bold,
                    )),
          ),
          Align(alignment: Alignment(0, 0.85), child: child),
        ],
      ),
      alignment: Alignment.bottomCenter,
    );
  }
}

///
/// 首页列表的header
///
class HomeRefreshHeader extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    RefreshString strings = RefreshLocalizations.of(context)?.currentLocalization ?? EnRefreshString();
    return ClassicHeader(
      textStyle: TextStyle(color: Colors.white),
      height: 70 + MediaQuery.of(context).padding.top / 3,
      outerBuilder: (child) => HomeSecondFloorOuter(child),
      twoLevelView: Container(),
      refreshingIcon: ActivityIndicator(brightness: Brightness.dark),
      releaseText: strings.canRefreshText,
    );
  }
}
//
// /// 通用的footer
// ///
// /// 由于国际化需要context的原因,所以无法在[RefreshConfiguration]配置
// class RefresherFooter extends StatelessWidget {
//   @override
//   Widget build(BuildContext context) {
//     return ClassicFooter();
//   }
// }
